{# Modal window for creating a new entity #}
{# requires: entityPage + {experiments,resources}CategoriesArr #}

<div class='modal fade' id='createModal_{{ entityPage }}' tabindex='-1' role='dialog' aria-labelledby='createModalLabel_{{ entityPage }}'>
  <div class='modal-dialog modal-lg' role='document'>
    <div class='modal-content'>
      <div class='modal-header'>
        <h5 class='modal-title' id='createModalLabel_{{ entityPage }}'>{{ entityPage == 'templates' or entityPage == 'resources-templates' ? 'Create a new template'|trans : 'Select a template below'|trans }}</h5>
        <button type='button' class='close' data-dismiss='modal' aria-label='{{ 'Close'|trans }}'>
          <span aria-hidden='true'>&times;</span>
        </button>
      </div>
      <div class='modal-body mb-3'>
      {% if entityPage == 'templates' or entityPage == 'resources-templates' %}
        <div id='createNewForm'>
          <label for='createNewModalTitleInput'>{{ 'Enter a title'|trans }}</label>
          <input name='title' required class='form-control' type='text' id='createNewModalTitleInput' />
        </div>
        {% else %}
          {% set btnId = 'createNewTemplates_' ~ entityPage %}
          <div class='d-flex flex-row justify-content-between mb-2'>
            {% set scopeTarget = entityPage == 'database' ? 'scope_items_types' : 'scope_experiments_templates' %}
            {% include 'scope-button.html' with {'btnId': btnId, 'reload': btnId ~ ',tplCreateNewDiv_' ~ entityPage, 'target': scopeTarget} %}
            {% set templatesPage = Entity.entityType.toTemplatePage()|default(entityPage == 'database' ? 'resources-templates.php' : 'templates.php') %}
            <a href='{{ templatesPage }}' class='btn btn-ghost btn-sm'><i class='fas fa-cogs mr-1'></i>{{ 'Manage templates'|trans }}</a>
          </div>

          {% set templatesArr = entityPage == 'experiments' ? templatesArr : itemsTemplatesArr %}
          {% include 'create-new-item-modal-body.html' %}
        {% endif %}
      </div>
        <div class='modal-footer'>
          <button type='button' class='btn btn-ghost' data-dismiss='modal'>{{ 'Cancel'|trans }}</button>
          {% if entityPage == 'templates' or entityPage == 'resources-templates' %}
            <button type='button' data-action='create-entity' data-type='{{ Entity.entityType.value }}' data-has-title='1' data-form-id='createNewForm' class='btn btn-primary'>{{ 'Create'|trans }}</button>
          {% endif %}
        </div>
    </div>
  </div>
</div>
{# end modal #}
